/*
 *  Copyright (C), 2015-2024
 *  FileName: life_cycle_observe
 *  Author: Tonight丶相拥
 *  Date: 5/16/24
 *  Description: 
 **/

part of 'flutter_tool.dart';

enum CustomAppLifeCycleState {
  detach('onDetach', '退出'),
  exitRequested('onExitRequested', '退出请求'),
  hide('onHide', '隐藏'),
  inActive('onInActive', '不活跃'),
  pause('onPause', '暂停'),
  restart('onRestart', '重启'),
  resume('onResume', '恢复'),
  show('onShow', '显示')
  ;
  const CustomAppLifeCycleState(this.rawValue, this.description);
  final String rawValue;
  final String description;

  @override
  String toString() {
    return "CustomAppLifeCycleState(rawValue: $rawValue, description: $description)";
  }
}


class _FlutterLifeCycleObserve extends AppLifecycleListener with _CustomNotification {
  _FlutterLifeCycleObserve._():super();

  static const String flutterLifeCircleStateChange = "flutterLifeCircleStateChange\$_FlutterLifeCircleObserve";

  /*
  @override
  // TODO: implement onExitRequested
  AppExitRequestCallback? get onExitRequested => (){
    return Future.value(AppExitResponse.exit);
  };
   */

  @override
  // TODO: implement onDetach
  VoidCallback? get onDetach => () {
    debugLog("AppLifeState Change: ${CustomAppLifeCycleState.detach}");
    notificationListener(name: flutterLifeCircleStateChange, parameter: CustomAppLifeCycleState.detach);
  };

  @override
  // TODO: implement onHide
  VoidCallback? get onHide => () {
    debugLog("AppLifeState Change: ${CustomAppLifeCycleState.hide}");
    notificationListener(name: flutterLifeCircleStateChange, parameter: CustomAppLifeCycleState.hide);
  };

  @override
  // TODO: implement onInactive
  VoidCallback? get onInactive => () {
    debugLog("AppLifeState Change: ${CustomAppLifeCycleState.inActive}");
    notificationListener(name: flutterLifeCircleStateChange, parameter: CustomAppLifeCycleState.inActive);
  };

  @override
  // TODO: implement onPause
  VoidCallback? get onPause => () {
    debugLog("AppLifeState Change: ${CustomAppLifeCycleState.pause}");
    notificationListener(name: flutterLifeCircleStateChange, parameter: CustomAppLifeCycleState.pause);
  };

  @override
  // TODO: implement onRestart
  VoidCallback? get onRestart => () {
    debugLog("AppLifeState Change: ${CustomAppLifeCycleState.restart}");
    notificationListener(name: flutterLifeCircleStateChange, parameter: CustomAppLifeCycleState.restart);
  };

  @override
  // TODO: implement onResume
  VoidCallback? get onResume => () {
    debugLog("AppLifeState Change: ${CustomAppLifeCycleState.resume}");
    notificationListener(name: flutterLifeCircleStateChange, parameter: CustomAppLifeCycleState.resume);
  };

  @override
  // TODO: implement onShow
  VoidCallback? get onShow => () {
    debugLog("AppLifeState Change: ${CustomAppLifeCycleState.show}");
    notificationListener(name: flutterLifeCircleStateChange, parameter: CustomAppLifeCycleState.show);
  };

  /*
  @override
  // TODO: implement onStateChange
  ValueChanged<AppLifecycleState>? get onStateChange => (AppLifecycleState state) {

  };*/
}